<html>
<head>
	<meta charset='utf-8' />
	<title>小区信息助手</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		
		@media screen and (max-width:450px){
			#content{width:98%;margin:0 auto;border:1px solid}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#content{width:450px;margin:0 auto;border:1px solid}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
	</style>
</head>
<body id='content'>
	<div style='padding-bottom:50px' id='main' class='l1'>

		<div style='margin:5px;font-size:12px;text-align:right'>
			<span style='color:red' onclick='location.href="createArea.html"'>创建小区</span>　
			<span>当前用户：</span>
			<span style='position:relative;width:15px;'>
				<img id='current_user_head' src="" alt="" style='position:absolute;top:-12px;width:15px;height:15px;border-radius:25px' />
			</span>　　
			<span id='current_user'>xxxx</span>　
			<span id='exit' style='color:blue'>退出</span>
		</div>

		<h2 style='text-align:center'>我的小区</h2>

		<div style='text-align:center;font-size:12px;margin:20px 0'>当前城市：<span id='current_county'></span></div>


		<div style='border:0px solid;text-align:center' id='area_list'>
			<div style='display:flex'>
				<div style='flex:2'>金达菜小区<span style='position:absolute;width:5px;height:5px;background:red;border-radius:25px'></span></div>
				<div style='flex:1'><span style='font:normal normal 12px/30px normal'>正常</span></div>
			</div>
		</div>

		<div style='text-align:center;margin:30px'><button onclick='location.replace("area_list.html")'>返回</button></div>

	</div>



</body>
</html>
<script src='../public/jquery.js'></script>
<script src='../public/fun.js'></script>
<script>
var user_info;
var tokenSet;




$(function(){
	GetUserInfo(function(user_info){
		//C(user_info);
		user_info = user_info;
		$('#current_user').text(user_info.nickname);
		$('#current_user_head').attr('src',user_info.headimgurl);

		GetTokenSet(function(tokenSet){
			tokenSet = tokenSet;
			$('#current_county').text(tokenSet[1]);

			//获取我的小区列表
			GetMyAreaList(tokenSet[0],function(area_list){
				//C(area_list);
				parse_data(area_list);
			},5000);
		});
	});




	//用户退出 
	$('#exit').click(function(){
		localStorage.user_info = '';
		location.reload();
	});


});

function parse_data(obj){
	var tmp_str = '';
	for(var i=0;i<obj.length;i++){
		//C(obj[i]);
		tmp_str += "<div style='display:flex'>";
			if(obj[i].stat == 1){
				tmp_str += "<div style='flex:2'>" +obj[i].area_name+ "<span style='position:absolute;width:5px;height:5px;background:red;border-radius:25px'></span></div>";
			}else{
				tmp_str += "<div style='flex:2' onclick=jump_area_detail("+obj[i].id+",'" + obj[i].area_name + "','me')>" +obj[i].area_name+ "<span style='position:absolute;width:5px;height:5px;background:red;border-radius:25px'></span></div>";
			}
			switch(obj[i].stat){
				case '1':case 1:var stat='审核中';break;
				case '2':case 2:var stat='正常';break;
				case '3':case 3:var stat='未通过';break;
			}
			tmp_str += "<div style='flex:1'><span style='font:normal normal 12px/30px normal'>" +stat+ "</span></div>";
		tmp_str += "</div>";
	}
	$('#area_list').html(tmp_str);
}




</script>